<template>
  <div>
    <a-modal title="置顶"
             :visible="visible"
             @ok="handleOk"
             :confirmLoading="confirmLoading"
             @cancel="handleCancel">
              <a-row>
      <a-input-number :min="1"
                      :max="10"
                      v-model="value"
                      @change="onChange" />
</a-row>
<a-divider dashed />
                   <a-row> <a-switch  v-model="recommend" checkedChildren="设为推荐" unCheckedChildren="取消推荐"/></a-row>

                   <a-divider dashed />
                   <a-row> <a-switch  v-model="notice" checkedChildren="设为公告" unCheckedChildren="取消公告"/></a-row>
 <a-divider dashed />
                    <a-row> <a-switch  v-model="hot" checkedChildren="设为热门" unCheckedChildren="取消热门"/></a-row>
    </a-modal>
  </div>
</template>
<script>
import { top } from '@/api/cms/content'
export default {
  data() {
    return {
      visible: false,
      confirmLoading: false,
      value: 0,
      recommend: false,
      notice: false,
      hot: false,
      record: {}
    }
  },
  methods: {
    top(record) {
      this.visible = true
      this.value = record.sort
      this.recommend = record.recommend
      this.notice = record.notice
      this.hot = record.hot
      this.record = record
    },
    handleOk(e) {
      const param = {
        id: this.record.id,
        recommend: this.recommend,
        notice: this.notice,
        hot: this.hot,
        sort: this.value
      }
      top(param).then(response => {
        if (response.code === 0) {
          this.$emit('ok')
          this.handleCancel()
          this.$message.info(response.msg)
        }else{
           this.$message.error(response.msg)
        }
      })
    },
    handleCancel(e) {
      this.visible = false
    },
    onChange(e) {

    }
  }
}
</script>
